package entity

import (
	"time"

	"shqsoft.cn/pasnj/base"

	"github.com/jinzhu/gorm"
)

//PHGDDR 短贷宝导入
type PHGDDR struct {
	ID     int        `gorm:"AUTO_INCREMENT;primary_key;column:ID"`
	KHYF   int        `gorm:"column:KHYF"`
	XH     int        `gorm:"column:XH"`
	CZJG   string     `gorm:"column:CZJG"`
	JJBH   string     `gorm:"column:JJBH"`
	KHMC   string     `gorm:"column:KHMC"`
	YWPZ   string     `gorm:"column:YWPZ"`
	DKQX   string     `gorm:"column:DKQX"`
	BJZE   float64    `gorm:"column:BJZE"`
	FFR    *time.Time `gorm:"column:FFR;type:date"`
	DQR    *time.Time `gorm:"column:DQR;type:date"`
	TS     float64    `gorm:"column:TS"`
	JZLL   float64    `gorm:"column:JZLL"`
	FDLL   float64    `gorm:"column:FDLL"`
	ZXLL   float64    `gorm:"column:ZXLL"`
	ZXNL   float64    `gorm:"column:ZXNL"`
	TJR1   string     `gorm:"column:TJR1"`
	TJRBM1 string     `gorm:"column:TJRBM1"`
	ZB1    float64    `gorm:"column:ZB1"`
	TJR2   string     `gorm:"column:TJR2"`
	TJRBM2 string     `gorm:"column:TJRBM2"`
	ZB2    float64    `gorm:"column:ZB2"`
	TJR3   string     `gorm:"column:TJR3"`
	TJRBM3 string     `gorm:"column:TJRBM3"`
	ZB3    float64    `gorm:"column:ZB3"`
	DRJG   string     `gorm:"column:DRJG"`
}

//TableName 短贷宝导入
func (PHGDDR) TableName() string {
	return "T_BASE_YXFY_PHGD_DTIP"
}

//PHGDDRAfterImport 导入后执行分户处理
func PHGDDRAfterImport(tx *gorm.DB, params map[string]string) (err error) {
	prams := make([]interface{}, 1)
	prams[0] = params["KHYF"]
	tx.Exec("EXEC UP_BASE_YXFY_PHGD_DTIP ?", prams...)
	return nil
}

//PHGDDREF 返回结构体
func PHGDDREF() base.EntityFunc {
	return func() interface{} {
		entity := PHGDDR{}
		return &entity
	}
}

//PHGDDRESF 返回结构体数组
func PHGDDRESF() base.EntitiesFunc {
	return func() interface{} {
		var entities []PHGDDR
		return &entities
	}
}

func init() {
	base.DaoPoolObj.Put("PHGDDR", base.NewDefaultDao(PHGDDREF(), PHGDDRESF(), nil))
	base.SetAfterCallBack("PHGDDR", PHGDDRAfterImport)
}
